<?php
abstract class Delivery_Model_Mapper_Abstract
	
{
	public function getIdentityMap()
	{
		return My_IdentityMap::getInstance();
	}
	
	public function getDbTable( $name )
	{
		return Delivery_Model_Factory::dbTable($name);
	}	
	
	public function getById( $id )
	{
		$rowset = $this->getDbTable()->getById( $id );
		return $this->_fetch( $rowset->current() );
	}
	
	public function getByIds( $ids )
	{
		return $this->_fetchCollection( 
			$this->getDbTable()->getByIds( $ids )
		);
	}
	
	protected function _fetchCollection( $name, $rowset )
	{
		
		$collection = Delivery_Model_Factory::collection( $name );
		
		foreach ( $rowset as $row){
			$collection->append(
				$this->_fetch( $row )
			);
		}
		
		return $collection;
	}
	
	public function logDeleted( $entity )
	{
		$logger = new Delivery_Model_Logger;
		$logger->logDeleted( $entity );
	}
	
	public function onlyActive( $onlyActive = true )
	{
		Delivery_Model_DbTable_Desactivable::onlyActive( $onlyActive );
	}
	
}